<template>
  <div class="wapper">
     <swiper :options="swiperOption">
    <!-- slides -->
        <swiper-slide v-for="item of list" :key="item.id" v-if="showSwiper">
          <img class="swiper-img" :src="item.imgUrl">
        </swiper-slide>
    <!-- Optional controlspicp -->
    <div class="swiper-pagination"  slot="pagination"></div>
    <!--    <div class="swiper-scrollbar"   slot="scrollbar"></div>  滚动条    -->
    <!--    <div class="swiper-button-prev" slot="button-prev"></div>
    <div class="swiper-button-next" slot="button-next"></div>       左右箭头       -->
    </swiper>
  </div>
</template>

<script>
export default {
  name: 'HomeSwiper',
  props: {
    list: Array
  },
  data () {
    return {
      swiperOption: {
        pagination: '.swiper-pagination', /* 设置小圆点 */
        loop: true /* 支持轮播 */
      }
    }
  },
  computed: { /* 计算轮播初始的时候显示的图片 */
    showSwiper () {
      return this.list.length
    }
  }
}
</script>

<style lang="stylus" scoped>
  .wapper
    overflow :hidden /* 宽高比例自适应 */
    width :100%
    height :0
    padding-bottom :26.6%  /* 解决网速慢卡屏，高度相对于宽度自动撑开一定比例 */
    .swiper-img
      width :100%

</style>
